package top.saodisheng.springcloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import top.saodisheng.springcloud.pojo.Dept;
import top.saodisheng.springcloud.service.DeptClientService;

import java.util.List;

/**
 * Description:
 *
 * @author 扫地生_saodisheng
 */

@RestController
public class DeptConsumerController {
    @Autowired
    private DeptClientService deptClientService;


    /**
     * 消费者添加部门信息
     *
     * @param dept
     * @return
     */
    @RequestMapping("/consumer/dept/add")
    public boolean add(Dept dept) {
        return deptClientService.addDept(dept);
    }


    /**
     * 消费者根据id查询部门信息
     *
     * @param id
     * @return
     */
    @RequestMapping("/consumer/dept/get/{id}")
    public Dept get(@PathVariable("id") Long id) {
        return deptClientService.queryById(id);
    }

    /**
     * 消费者查询部门信息列表
     *
     * @return
     */
    @RequestMapping("/consumer/dept/list")
    public List<Dept> list() {
        return deptClientService.queryAll();
    }
}
